package com.itheima.stream;

import java.util.ArrayList;
import java.util.function.Predicate;

public class StreamDemo03 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("zhang");
        list.add("wang");
        list.add("lisi");
        list.add("zhao");
        list.stream().filter((String s)->{
            return s.startsWith("z");
        }).filter((String s)->{return s.length()==4;}).forEach(s-> System.out.println(s));
        list.stream().filter(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                boolean result = s.startsWith("z");
                return result;
            }
        }).filter(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.length() == 4;
            }
        }).forEach(s-> System.out.println(s));
        list.stream().filter(s->s.startsWith("z")).filter(s->s.length()==4).forEach(s-> System.out.println(s));
    }
}
